{include file="header.html"}
<script src="/js/ckeditor/ckeditor.js"></script>
<div class="page-header">
	<h6>
		操作日志
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			日志详情
		</small>
	</h6>
</div>
<div class="row">
<div class="col-xs-12">
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right" for="name"> 操作内容 </label>
		<div class="col-sm-10">
			<textarea style="width: 940px;height: 600px;font-size: 15px;line-height: 35px;">
				{$rs->content}
			</textarea>
		</div>
	</div>
</div>
</div>
<script>
function deletePic(k){
	if(!confirm('是否删除？'))return;
	$(k).parent().remove();
	if($('#imgs').children().length<6)$('#file').show();
}
function setDragsort(){
	$('#imgs').dragsort({
		dragList : 'div',
		dragItem : 'span',
		//lockRange : true,
		placeHolder : '<div class="hold"></div>',
		start : function(){
			$('.hold').html(this.html()).attr('style', this.attr('data-style')).css({
				width:this.outerWidth(false),
				height:this.outerHeight(false),
				opacity:0.3
			});
		}
	});
}
$(function(){
	setDragsort();
	$('#simple-table').on('click', 'a.del', function(){
		$(this).parent().remove();
	});
	//添加图片
	$('#files').html5upload({
		url : '?app=article&act=upload_pic',
		name : 'pic',
		dataType : 'text',
		before : function(){
			if($('#imgs').children().length>=6){
				alert('图片不可超过6张');
				return false;
			}
			$.overload();
		},
		success : function(url){
			$.overload(false);
			var html = '<div>\
				<span title="拖动改变顺序">≡</span>\
				<a href="'+url+'" target="_blank" style="background-image:url('+url+');"></a>\
				<input type="hidden" name="pics[]" value="'+url+'" />\
				<a href="javascript:void(0)" onclick="deletePic(this)"></a>\
			</div>';
			$('#imgs').append(html);
			if($('#imgs').children().length>=6)$('#file').hide();
			setDragsort();
		}
	});
    $('#add').click(function(){
		var style = '', win = $.window();
		if(win.width<=768)style = 'style="width:'+win.width+'px;height:'+win.height+'px;"';
		var html = '<div class="goods" '+style+'>\
			<div class="goods-title"><a href="javascript:void(0)">×</a>搜索商品</div>\
			<input type="text" class="keywords" placeholder="输入商品关键字后回车进行搜索" />\
			<ul class="goods-list"></ul>\
		</div>';
        $.overlay(html, 0, null, function(){
			$('.goods .goods-list').stopScroll(false);
		});
		$('.goods .goods-title a').click(function(){
			$.overlay(false);
		});
		$('.goods .goods-list').stopScroll(true);
		$('.goods .keywords').onkey({
			callback : function(code){
				if(code==13){
					var _this = $(this);
					if(!_this.val().length){ alert('请输入关键字');return }
					$.getJSON('api.php?app=goods&act=index&keyword='+_this.val(), function(json){
						if(json.error!=0){ alert('请输入关键字');return }
						if(!$.isArray(json.data.rs)){ alert('搜索不到相关商品');return }
						var html = '';
						for(var i=0; i<json.data.rs.length; i++){
							html += '<li class="item">\
								<a href="javascript:void(0)">\
									<div style="background-image:url('+json.data.rs[i].pic+');"></div>\
									<span>'+json.data.rs[i].name+'</span>\
									<font>￥'+json.data.rs[i].price+'</font>\
								</a>\
							</li>';
						}
						$('.goods .goods-list').html(html);
						$('.goods .goods-list a').each(function(i){
							$(this).data('data', json.data.rs[i]).click(function(){
								//$.overlay(false);
								var data = $(this).data('data'), hasGoods = false;
								$('.goods_id').each(function(){
									if(Number($(this).val())==Number(data.id)){
										hasGoods = true;
										return false;
									}
								});
								if(hasGoods)return;
								var html = '<li class="item">\
									<a class="del" href="javascript:void(0)">－</a>\
									<a href="index.php?app=goods&act=edit&id='+data.id+'" target="_blank">\
										<div style="background-image:url('+data.pic+');"></div>\
										<span>'+data.name+'</span>\
										<font>￥'+data.price+'</font>\
									</a>\
									<input type="hidden" class="goods_id" name="goods[]" value="'+data.id+'" />\
								</li>';
								$('#simple-table').append(html);
							});
						});
					});
				}
			}
		});
    });
});
</script>
{include file="footer.html"}
